home *** CD-ROM | disk | FTP | other *** search
- //____________________________________________________________
- // SelectMovie.c
- //
- // Copyright © Dan Parks Sydow, 1995
- // From the book:
- // "Graphics and Sound Programming Techniques for the Mac",
- // M&T Books, 1995
-
-
- //____________________________________________________________
-
- #include <Movies.h>
-
-
- //____________________________________________________________
-
- void InitializeAllToolboxes( void );
-
-
- //____________________________________________________________
-
- #define rMovieWindow 128
-
-
- //____________________________________________________________
-
- void main( void )
- {
- OSErr theError;
- FSSpec theFSSpec;
- short theFileRefNum;
- Movie theMovie;
- short theMovieResID = 0;
- Str255 theMovieResName;
- Boolean wasAltered;
- WindowPtr theWindow;
- Rect theMovieBox;
- SFTypeList typeList = { MovieFileType, 0, 0, 0 };
- StandardFileReply theReply;
-
- InitializeAllToolboxes();
-
- StandardGetFilePreview( nil, 1, typeList, &theReply );
-
- if ( theReply.sfGood == true )
- {
- theError = OpenMovieFile( &theReply.sfFile, &theFileRefNum, fsRdPerm );
- theError = NewMovieFromFile( &theMovie, theFileRefNum, &theMovieResID,
- theMovieResName, newMovieActive, &wasAltered );
- CloseMovieFile( theFileRefNum );
- }
- else
- {
- ExitToShell();
- }
-
- theWindow = GetNewCWindow( rMovieWindow, nil, (WindowPtr)-1L );
-
- SetMovieGWorld( theMovie, (CGrafPtr)theWindow, nil );
-
- GetMovieBox( theMovie, &theMovieBox );
- OffsetRect( &theMovieBox, -theMovieBox.left, -theMovieBox.top );
- SetMovieBox( theMovie, &theMovieBox );
-
- SizeWindow( theWindow, theMovieBox.right, theMovieBox.bottom, true );
- ShowWindow( theWindow);
-
- GoToBeginningOfMovie( theMovie );
-
- StartMovie( theMovie );
-
- do
- {
- MoviesTask(theMovie, 0);
- }
- while ( IsMovieDone( theMovie ) == false );
-
- DisposeMovie( theMovie );
- DisposeWindow( theWindow );
- }
-
-
- //____________________________________________________________
-
- void InitializeAllToolboxes( void )
- {
- OSErr theError;
- long theResult;
-
- InitGraf( &qd.thePort );
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( 0L );
- FlushEvents( everyEvent, 0 );
- InitCursor();
-
- theError = Gestalt( gestaltQuickTime, &theResult );
- if ( theError != noErr )
- ExitToShell();
-
- theError = EnterMovies();
- if ( theError != noErr )
- ExitToShell();
- }
-
-
-
-